from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from config import DATABASE_URL

# 创建数据库引擎
engine = create_engine(DATABASE_URL)

# 创建会话
Session = sessionmaker(bind=engine)

# 检查连接是否成功
try:
    connection = engine.connect()
    print("Connected to MySQL database")
    connection.close()
except Exception as e:
    print(f"Failed to connect to MySQL database: {e}")